<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/cash_fir.css')}}">
    <script src="{{asset('/js/web/find/jquery.form.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">余额提现</div>
                <div class="content">
                    <div class="navbox w-f f-cb">
                        <a class="link" href="{{asset('buyer/withdrawal_apply')}}" data-id="1">银行卡提现</a>
                        <a class="link hover" href="{{asset('buyer/withdrawal_apply?type=2')}}" data-id="1">支付宝提现</a>
                    </div>
                    <div class="top-explain">
                        <p class="tt">提现说明：</p>
                        <span class="word">
							<p>1、每天提现次数最多3次。
                                
                                    <span style="color:red;">您今日的申请次数已达上限！</span>
                                
                                    您已申请<span style="color:red;"></span>次
                                
                            </p>
							<p>2、请仔细填写您的个人信息以及支付宝账户，方便工作人员及时与您联系。</p>
							<p>3、提现方式以线下转账方式进行。</p>
							<p>4、E井在线拥有最终解释权。</p>
						</span>
                    </div>
                    <div class="tab-box">
                        
                            <a href="/member/pay_revise"><button type="button" class="btn btn-primary">您还未设置支付密码，点击设置支付密码!</button></a>
                        
                            <div>您今日的申请次数已达上限，请明日再试！</div>
                        
                            <div>您的城市合伙人账户已被锁定，无法进行提现！客服热线：400-016-6889</div>
                        
                            <form action="" id="frm_post">
                                {{csrf_field()}}
                                <table>
                                    <tr>
                                        <td class="tt" width="150">可提现金额：</td>
                                        <td><span class="f26 red">150</span>元</td>
                                    </tr>
                                    <tr>
                                        <td height="6"></td>
                                    </tr>
                                    <tr>
                                        <td class="tt"><span class="star">*</span>　姓名：</td>
                                        <td>
                                            <input name='name' class="tex fl name" type="text" onblur="" onfocus="" placeholder="请输入您的姓名">
                                            <span class="jm_error"></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="6"></td>
                                    </tr>
                                    <tr>
                                        <td class="tt"><span class="star">*</span>　联系方式：</td>
                                        <td><input name='phone' class="tex phone" type="text" onblur="" placeholder="手机" ><span class="jm_error"></span></td>
                                    </tr>
                                    <tr>
                                        <td height="6"></td>
                                    </tr>
                                    <tr>
                                        <td class="tt"><span class="star">*</span>　支付宝账号：</td>
                                        <td><input name='account' class="tex account" type="text" onblur="" placeholder="请输入您的支付宝账号" ><span class="jm_error"></span></td>
                                    </tr>
                                    <tr>
                                        <td height="6"></td>
                                    </tr>
                                    <tr>
                                        <td class="tt"><span class="star">*</span>　申请提现金额：</td>
                                        <td><input name='money' class="tex fl money" type="text" onblur="" onfocus="" placeholder="请输入您的金额" ><span class="fl">元</span><span class="jm_error"></td>
                                    </tr>
                                    <tr>
                                        <td height="6"></td>
                                    </tr>
                                    <tr>
                                        <td class="tt"><span class="star">*</span>　支付密码：</td>
                                        <td><input name='paypwd' class="tex fl paypwd" type="password" placeholder="请输入您的密码"><span class="jm_error"></td>
                                    </tr>
                                </table>
                                <input type="hidden" name="type" value="2">
                                <div class="button-group">
                                    <input type="submit" class="sub-btn jm_btn6 submit" value="提交申请">
                                    <a href="/buyer/balance"><div class="jm_btn4">返回</div></a>
                                </div>
                            </form>
                        
                    </div>
                    <div class="bot-font">
                        <p>您的提现申请会在3个工作日内审核（周末提现打款顺延），请耐心等待。客服热线：400-016-6889</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')

<script>
    $(function(){
        var maxMoney= 252;
        var reg= /(^(([0-9]+\.[0-9]{1,2})|([0-9]*[1-9][0-9]*\.[0-9]{1,2})|([0-9]*[1-9][0-9]*))$)/;

        $('.money').keyup(function () {
            this.value = this.value.replace(/[^\d.]/g, "");
            if (reg.test(this.value) && 0 < this.value && this.value <= maxMoney) {
                errorHide($(this));
            } else if (this.value > maxMoney) {
                errorShow($(this),'您可提现的最大金额为' + maxMoney)
                $(this).val(maxMoney);
            } else {
                errorShow($(this),'您的金额填写有误，最小金额为1分')
            }
        })

        $(".submit").on('click',function(event) {
            event.preventDefault();
            /* Act on the event */
            $('#frm_post').ajaxSubmit({
                type: 'post', // 提交方式 get/post
                url: 'withdrawal_apply/post', // 需要提交的 url
                beforeSubmit:showRequest,
                success:showResponse
            });
            function showRequest() {
                $all_status = true;

                if($("input[name='name']").val() == ''){
                    errorShow($("input[name='name']"),'请输入您的姓名');
                    $all_status = false;
                }else{
                    errorHide($("input[name='name']"));
                }

                var re = /[\u4e00-\u9fa5]/;
                if($("input[name='name']").val() && !re.test($("input[name='name']").val())) {
                    errorShow($("input[name='name']"),'姓名必须为中文');
                    $all_status = false;
                } else if($("input[name='name']").val()) {
                    errorHide($("input[name='name']"));
                }

                if($("input[name='account']").val() == ''){
                    errorShow($("input[name='account']"),'请输入您的支付宝账户');
                    $all_status = false;
                }else{
                    errorHide($("input[name='account']"));
                }

                if($("input[name='money']").val() == ''){
                    errorShow($("input[name='money']"),'请填写需要提现的金额');
                    $all_status = false;
                }else{
                    errorHide($("input[name='money']"));
                }

                if ($("input[name='paypwd']").val().length < 6) {
                    errorShow($("input[name='paypwd']"),'密码长度不小于6位');
                    $all_status = false;
                } else {
                    errorHide($("input[name='paypwd']"));
                }

                var isPhone = /(?:\(\d{3,4}\)|\d{3,4}-?)\d{8}/;//手机号码验证
                if (!isPhone.test($('input[name="phone"]').val())) {
                    errorShow($("input[name='phone']"),'联系方式必须是手机号码或座机');
                    $all_status = false;
                } else {
                    errorHide($("input[name='phone']"));
                }

                if(!$all_status){
                    return false;
                }
            }
            function showResponse(data, statusText) {
                if (data.code == 0) {
                    layer.alert('您已成功提交提现申请，我们将及时为您处理！', {icon: 1}, function () {
                        location.href = '/buyer/balance';
                    });
                } else {
                    layer.alert(data.message, {icon: 2});
                }
            }

        });
    })

    //表单错误显示
    function errorShow(input, msg){
        input.parent('.input_error .jm_error').html('');
        input.parent('.input_error').removeClass('jm_input_error');
        input.addClass('error').focus().nextAll('.jm_error').html(msg);
        input.parent('.input_error').addClass('jm_input_error');
        return false;
    }

    //表单正确显示
    function errorHide(input){
        input.parent('.input_error').addClass('jm_input_error');
        input.removeClass('error').focus().nextAll('.jm_error').html('');
        input.parent('.input_error').removeClass('jm_input_error');
        return true;
    }

</script>
</body>
</html>